Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes in power_rev #55

Open
wants to merge 4 commits into
base: IA_1.0-dev
Choose a base branch
from
Open

Fixes in power_rev #55

wants to merge 4 commits into from

Conversation

lbenet
Copy link
Member

@lbenet lbenet commented May 28, 2022

No description provided.

@lbenet
Copy link
Member Author

lbenet commented May 28, 2022

Included the Manifest.toml to use 1.0-dev branch in IA

@lbenet
Copy link
Member Author

lbenet commented May 28, 2022

Once JuliaIntervals/IntervalArithmetic.jl#533 is merged (in 1.0-dev branch), all should pass.

@lbenet
Copy link
Member Author

lbenet commented May 28, 2022

The remaining broken tests are some edge cases...

@lucaferranti
Copy link
Member

lucaferranti commented May 29, 2022

with this branch some broken tests are not broken anymore, but it also introduces some new failures, both using 1.0-dev and JuliaIntervals/IntervalArithmetic.jl#533 🤔. Is 533 rebased to 1.0-dev?

@lbenet
Copy link
Member Author

lbenet commented May 29, 2022

I think JuliaIntervals/IntervalArithmetic.jl#533 branch includes the changes in .lo and .hi (JuliaIntervals/IntervalArithmetic.jl#531), so I would say yes, it includes changes already in 1.0-dev.

I agree, it seems that it creates some new failures. I think those failures are related to the properties of the implementation that I'm trying to clarify. I don't think those aspects are related to the implementation in IA, but in the way that pow_rev is implemented here.

It should use the last commit in the 1.0-dev branch
@lucaferranti
Copy link
Member

lucaferranti commented Jun 2, 2022

hups, I had a small misunderstanding in JuliaIntervals/IntervalArithmetic.jl#533 . In my head I was only thinking about pow_rev1 and pow_rev2, but now I see you were talking about power_rev.

I'll take another look at this before / after 533 now that I know what I'm talking about :)

@@ -19,7 +19,7 @@ function plus_rev(a::Interval, b::Interval, c::Interval) # a = b + c
return a, b_new, c_new
end

plus_rev(a,b,c) = plus_rev(promote(a,b,c)...)
plus_rev(a::F, b::F, c) where {T, F<:Interval{T}} = plus_rev(a, b, F(c))
Copy link
Member

@lucaferranti lucaferranti Jun 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this (and the others) be

function plus_rev(a::Interval{T}, b::Interval{S}, c::Interval(R})
  TSR = promote_type(T, S, R) # not sure if you can do it in one line, but you get the idea
  F = Interval{TSR}
  return plus_rev(F(a), F(b), F(c))
end

but it gets pretty tedious... I get the idea of not having promotion Float64 --> Interval{Float64}, but I think a promotion rule for Interval{T}, Interval{S} would be harmless.

In both cases something like plus_rev(1.0, 1..2, 3..4) wouldn't work. This can be a bug (if you think in the more ducktyping way) or a feature (if you come from a strong static typing programming language)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the second method, which previously had a promotion, I truly don't recall what was the motivation. I guess it was a way of avoiding using promote...

In any case, let me note that many operations in the 1.0-dev branch of IA impose the same Interval{T} for the operands: e.g., (1.0f0 .. 2.f0) - ( 1.5 .. 2.5) throws a MethodError due to ambiguities...

Copy link
Member

@lucaferranti lucaferranti Jun 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's because of ambiguity, then it's a bug (or at least misleading error message). In general, it's not necessarily wrong to disallow implicit conversions, strongly typed languages do it and for good reasons (see this accident ), but it doesn't feel julian, also for every function with multiple arguments you would need to manually 1) either define methods for all possible missing cases 2) or have an own interval _promote_interval to have things like f(1.0, 1..2, 2.0) work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this is probably tangential to this PR

@lbenet
Copy link
Member Author

lbenet commented Jun 3, 2022

hups, I had a small misunderstanding in JuliaIntervals/IntervalArithmetic.jl#533 . In my head I was only thinking about pow_rev1 and pow_rev2, but now I see you were talking about power_rev.

Sorry, my mistake... I don't remember what was the motivation to make those changes, apart from having a similar coding style than in 1.0-dev... Should I revert those changes, and only concentrate in the power_rev function(s) here?

@lucaferranti
Copy link
Member

no need to revert, it's a good PR and it does fix a few tests (don't know why everything is failing, will investigate soon). Apart for my one comment (which can also be delegated to further PRs) LGTM

@dpsanders
Copy link
Member

Sorry for the very late response... What's the status here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants